<?php

use think\facade\Route;

//
Route::group("v1/api", function () {
    Route::group(function () {
        Route::get('hello/<id?>', 'hello');
        Route::get('test/<id?>', 'test');
    })->prefix('\app\api\controller\v1\Test@');

    // movie controller
    Route::group(function () {
        // 获取电影列表
        Route::post('movie', 'movieList')
            ->validate([
                'page' => 'integer',
                'limit' => 'integer'
            ]);
        // 获取豆瓣Top250电影列表
        Route::post('douBanTop', 'douBanTop')
            ->validate([
                'page' => 'integer',
                'limit' => 'integer'
            ]);
        // 搜索电影
        Route::rule('searchMovie/<name?>/<page?>/<limit?>', 'searchMovieByName', 'GET|POST');
    })->prefix('\app\api\controller\v1\Movie@');

    // user controller
    Route::group(function () {
        // 登陆
        Route::post('login', 'login')
            ->validate([
                'email' => 'require|email',
                'password' => 'require|length:32'
            ]);
        // 通过RefreshToken获取jwtToken
        Route::rule('refreshToken', 'refreshToken', 'GET|POST')
            ->allowCrossDomain([
                'Access-Control-Allow-Headers' => 'Refresh-Token',
            ]);
        // 取消token
        Route::rule('cancelToken', 'cancelToken', 'GET|POST');
    })->prefix('\app\api\controller\v1\User@');
});

Route::group("v1/api", function () {
    // 获取上传token
    Route::group(function () {
        Route::get('getQiNiuToken', 'getQiNiuToken');
    })->prefix('\app\api\controller\v1\QiNiu@');
    // 获取七牛云列表
    Route::group(function () {
        Route::get('getQiuNiuList', 'getQiuNiuList');
    })->prefix('\app\api\controller\v1\QiNiu@');
});